package cn.tedu.net.collection.oop;
/*
本类用于opp综合练习
 */
public class Test3_Teacher {
    public static void main(String[] args) {
        Teacher tea1 =new Teacher();
        Teacher tea=new Teacher("刘德华","男",62,20000);//创建Teacher类的对象
        System.out.println("我叫"+tea.outName()+" 性别"+tea.outGender()+" 年龄"+ tea.outAge()+" 工资"+ tea.outSalary());
        System.out.println(tea1.outName());
        tea1.inName("李小璐");
        System.out.println(tea1.outName());

    }

}
class Teacher{
  //提供属性并封装
  private String name ;//姓名
  private String gender ;//性别
  private int    age;    //年龄
  private double salary; //工资
    /*构造方法:与类同名,且没有返回值类型的方法
    * 构造方法的作用:创建对象时使用
    * 调用时机:创建对象时立即调用
    * 如果什么构造方法都没有创建,默认会存在无参构造
    * 如果自定义了一个构造方法,默认的无参就被覆盖了,需要手动添加
    * 创造多个构造方法就是为了给调用的选择多种多样
    * */
    //添加无参构造方法
    public Teacher(){
        System.out.println("哈哈哈哈,我是无参构造方法");
    }
    //添加全参构造方法
    public Teacher(String name, String gender, int age, double salary) {
        this.name = name;
        this.gender = gender;
        this.age = age;
        this.salary = salary;
        System.out.println("哈哈哈哈,我是全参构造方法");
    }

    //提供行为不封装
    public void teach(){
        System.out.println("勤恳的打工人");
    }

    public String outName() {
        return name;
    }

    public void inName(String name) {
        this.name = name;
    }

    public String outGender() {
        return gender;
    }

    public void inGender(String gender) {
        this.gender = gender;
    }

    public int outAge() {
        return age;
    }

    public void inAge(int age) {
        this.age = age;
    }

    public double outSalary() {
        return salary;
    }

    public void inSalary(double salary) {
        this.salary = salary;
    }
}